#!/bin/python
# code snippet illustrating input/output methods 
N, K = raw_input().split()
N = int(N)
K = int(K)
C = []

numbers = raw_input()

i = 0
for number in numbers.split():
    C.append( int(number) )
    i = i+1
levels = N/K
C.sort(reverse=True)
if N % K != 0:
    levels = levels + 1

total = 0
for i in xrange(levels):
    for j in xrange(K):
        if i * K + j < N:
            total = total + (i+1) * C[i * K + j]       
print total

